package com.demo.richText.controller;


import com.demo.richText.framework.CommonController;
import com.demo.richText.pojo.vo.ReShowArticle;
import com.demo.richText.pojo.vo.ToSaveArticle;
import com.demo.richText.service.ArticleService;
import com.demo.richText.util.FileUtil;
import com.demo.richText.util.ResultResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 小王八
 * @since 2022-09-05
 */
@RestController
@Api(tags = "富文本文章操作")
@RequestMapping("/article")
@Validated
public class ArticleController extends CommonController {
    @Autowired
    private ArticleService articleService;

    @PostMapping("/toSaveArticle")
    @ApiOperation("保存文章")
    public ResultResponse<String> toSaveArticle(@RequestBody  ToSaveArticle toSaveArticle) {
        return process(() -> articleService.toSaveArticle(toSaveArticle));

    }
    @GetMapping("/toQueryArticle")
    @ApiOperation("查询文章")
    public ResultResponse<ReShowArticle> toQueryArticle(@RequestParam Long articleId) {
        return process(() -> articleService.toShowArticle(articleId));

    }
}
